#pragma once
#include <QObject>
#include <QTimer>
#include <rclcpp/rclcpp.hpp>
#include <QThread>
#include "heartbeat_listener.h"
#include "src/task_action_client.h"

class ROSWorker : public QObject {
    Q_OBJECT
public:
    explicit ROSWorker(HeartbeatModel* model, QObject* parent = nullptr);
    ~ROSWorker();
    HeartbeatListener* listener() const { return listener_.get(); }
    
    // 添加TaskClientNode到执行器的方法
    void addTaskClientNode(TaskClientNode* client);
    
    //RobotStatusClient* robotStatusClient() const { return robotStatusClient_.get(); }
    //MapDownloadActionClient* mapDownloadClient() const { return mapDownloadClient_.get(); }

public slots:
    void start();  // 启动ROS节点
    void stop();   // 安全停止

private:
    std::shared_ptr<HeartbeatListener> listener_;
    //std::shared_ptr<TaskClientNode> taskClientNode_;
    //std::shared_ptr<RobotStatusClient> robotStatusClient_;
    //std::shared_ptr<MapDownloadActionClient> mapDownloadClient_;
    rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_;
    QThread workerThread_;
    QTimer spinTimer_;
};